<?php

/**
 * @Author: Bing
 * @Date:   2019-04-14 20:03:01
 * @Email:  huangfreeze@gmail.com
 * @Last Modified time: 2019-04-20 11:00:03
 */

use Phinx\Migration\AbstractMigration;

/**
 * 添加微信用户表
 */
class WechatUserInfo extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('iwebshop_wechat_user_info');
        $table->addColumn('user_id', 'integer', array('limit' => 11))
              ->addColumn('openid', 'string', array('null' => true, 'limit' => 50))
              ->addColumn('nickname', 'string', array('null' => true, 'limit' => 200))
              ->addColumn('sex', 'integer', array('limit' => 1))
              ->addColumn('language', 'string', array('null' => true, 'limit' => 20))
              ->addColumn('city', 'string', array('null' => true, 'limit' => 100))
              ->addColumn('province', 'string', array('null' => true, 'limit' => 100))
              ->addColumn('country', 'string', array('null' => true, 'limit' => 100))
              ->addColumn('headimgurl', 'text', array('null' => true, ))
              ->addColumn('privilege', 'text', array('null' => true, ))
              ->addColumn('unionid', 'string', array('null' => true, 'limit' => 50))
              ->addIndex(array('openid'))
              ->addIndex(array('unionid'))
              ->addTimestamps()
              ->create();
    }
}
